home *** CD-ROM | disk | FTP | other *** search
- Path: rcp6.elan.af.mil!rscernix!danpop
- From: danpop@mail.cern.ch (Dan Pop)
- Newsgroups: comp.lang.c
- Subject: Re: Tradition or what?
- Date: 4 Mar 96 17:51:12 GMT
- Organization: CERN European Lab for Particle Physics
- Message-ID: <danpop.825961872@rscernix>
- References: <4g0elg$mdr@redstone.interpath.net> <4h0bbo$c0q@fohnix.metronet.com> <4h7ce0$ojd@news.interpath.net> <4h85sm$lm0@texas.nwlink.com>
- NNTP-Posting-Host: ues5.cern.ch
- X-Newsreader: NN version 6.5.0 #7 (NOV)
-
- In <4h85sm$lm0@texas.nwlink.com> Teresa Reiko <tjr19@mail.nwlink.com> writes:
-
- >In this book and others, notably 'Code Complete', these programming
- >guides published by Microsoft Press, it is evident why Microsoft put
- >so many bugs in Windows 95. Here are the three worst Microsoft
- >coding rules, in my opinion at least:
- >
- >Every line of code must contain a comment.
- >Any number greater than 2 must be a named constant.
- >No procedure may be longer than 25 lines.
- >
- >If you follow these rules, you can be sure to write buggy, inefficient
- >code that is difficult to revise and will generally look 'dirty'.
- >Of course, if this is your intent, that's OK, but...
-
- Actually, the second rule is quite good (except that '2' should be replaced
- by '1' :-) Magic constants embedded in the code are a huge nuisance
- for maintenability. If you have to change an explicit (aka magic) constant
- in a piece of code, how can you be sure that you aren't going to break
- anything? By changing a macro definition, you _know_ that you won't
- break anything, because all the dependencies of that macro will be
- automatically taken care of by the compiler (and your "make" utility).
-
- In a previous life, my boss was also doing Fortran programming. All his
- array dimensions were funny looking numbers (e.g. instead of the popular
- ARRAY(100,100) he would use ARRAY(99,101)), so that he could use his
- text editor to find all the places which needed to be changed when one
- of the arrays had to be redimensioned.
-
- Dan
- --
- Dan Pop
- CERN, CN Division
- Email: danpop@mail.cern.ch
- Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
-